package demos;

import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;

public class TimerTest {
	public static void main(String[] args) throws InterruptedException {
		Timer timer = new Timer(true);
		timer.schedule(new TimerTask() {
			private int count = 0;
			
			@Override
			public void run() {
				System.out.println(count++);
			}
		}, 1000, 500);
		TimeUnit.SECONDS.sleep(5);
		timer.cancel();
	}
}
